package game.source.manager.level;

import game.source.gui.GamePanel;
import game.source.manager.GameManager;
import game.source.util.Timer;
import game.source.util.TimerListener;

import java.awt.Point;



/**
 *Level1:
 *	Classe utilizada para gerenciar a fase:
 *	Determina aonde e quando os elementos aparecerão na tela
 */
public class Level1 extends GameManager implements TimerListener{
	private Timer	timer;	//Controla o tempo.
	private int		time;	//Armazena o tempo atual desde o início da partida.
	public Level1(GamePanel painel){
		super("/images/background/bg.png", painel);
		this.timer	= new Timer(this,1000);
		this.time 	= 0;
		this.timer.start();
	}
	
	@Override
	public void update() {
		this.time += (int)(this.timer.getDelta()/1000);
		switch(time){
		case 3:	//Cria um inimigo no primeiro segundo do jogo
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			break;
		case 10://Cria um inimigo no décimo segundo do jogo
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 11:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			break;
		case 12:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 20:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 21:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_01);
			break;
		case 26:
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 28:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			break;
		case 35:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 45:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_01);
			break;
		case 50:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 60:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_01);
			break;
		case 63:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			break;
		case 67:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 69:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 75:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
		case 76:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_03);
			break;
		case 77:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_01);
			break;
		case 85:
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 86:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			break;
		case 87:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 88:
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 89:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			break;
		case 90:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 95:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_01);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_01);
			break;
		case 97:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 99:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 105:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 106:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_03);
			break;
		case 107:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 108:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_03);
			break;
		case 109:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_02);
			break;
		case 110:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_03);
			break;
		case 115:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 120:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 130:
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			break;
		case 131:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 132:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_03);
			break;
		case 133:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 134:
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 135:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.ENEMY_03);
			break;
		case 140:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_02);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_02);
			break;
		case 145:
			this.createEnemy(new Point(this.getPanelWidth()/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth()*3/4,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(0,0),EnemyType.ENEMY_03);
			this.createEnemy(new Point(this.getPanelWidth(),0),EnemyType.ENEMY_03);
			break;
		case 160:
			this.createEnemy(new Point(this.getPanelWidth()/2,0),EnemyType.BOSS);
			break;
		}
	}

	@Override
	public void play() {
		super.play();
		this.timer.play();
		
	}

	@Override
	public void pause() {
		super.pause();
		this.timer.pause();
	}

	@Override
	public void end(){
		super.end();
		this.timer.end();
	}
}
